
'''
生成所有可能的by离子表格
'''

import json
import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)

def read_json(path):
    with open(path,'r',encoding='utf8')as fp:
        json_data = json.load(fp)
    return json_data

DATA=read_json("data.json")
amino_acids=read_json("amino_acid.json")
Water_weight=amino_acids[1]["Monoisotopic Mass"]
H_weight=amino_acids[2]["Monoisotopic Mass"]/2
data={'Name': list(), 
      'Letter': list(), 
      'Mass_no_water': list(),
      'b1-1 charge':list(),
      'y1-1 charge':list(),
      'b1-2 charge':list(),
      'y1-2 charge':list()}
for ac in amino_acids[0]["info"]:
    data["Name"].append(ac["Name"])
    data["Letter"].append(ac["OneLetter"])
    w=ac["Monoisotopic Mass"]-Water_weight
    data["Mass_no_water"].append(w)
    data["b1-1 charge"].append(w+H_weight)
    data["y1-1 charge"].append(w+Water_weight+H_weight)
    data["b1-2 charge"].append((w+2*H_weight)/2)
    data["y1-2 charge"].append((w+Water_weight+2*H_weight)/2)

print(pd.DataFrame(data))